/**
 * Weld joint definition. You need to specify local anchor points
 * where they are attached and the relative body angle. The position
 * of the anchor points is important for computing the reaction torque.
**/
public class b2WeldJointDef extends b2JointDef {

	public b2WeldJointDef()
	{
		type = b2JointType.e_weldJoint;
		localAnchorA = new b2Vec2(0.0f, 0.0f);
		localAnchorB = new b2Vec2(0.0f, 0.0f);
		referenceAngle = 0.0f;
		frequencyHz = 0.0f;
		dampingRatio = 0.0f;
	}

	public void release() {
		localAnchorA.release();
		localAnchorB.release();
	}

	/// Initialize the bodies, anchors, and reference angle using a world
	/// anchor point.
	public void Initialize(b2Body bodyA, b2Body bodyB, b2Vec2 anchor) {
		this.bodyA = bodyA;
		this.bodyB = bodyB;

		referenceAngle = jni_b2WeldJointDef_Initialize(
			localAnchorA.address, localAnchorB.address,
			bodyA.address, bodyB.address,
			anchor.address);
	}

	private static native float jni_b2WeldJointDef_Initialize(
			int localAnchorA, int localAnchorB,
			int bodyA, int bodyB, int anchor);

	/// The local anchor point relative to bodyA's origin.
	public b2Vec2 localAnchorA;

	/// The local anchor point relative to bodyB's origin.
	public b2Vec2 localAnchorB;

	/// The bodyB angle minus bodyA angle in the reference state (radians).
	public float referenceAngle;
	
	/// The mass-spring-damper frequency in Hertz. Rotation only.
	/// Disable softness with a value of 0.
	public float frequencyHz;

	/// The damping ratio. 0 = no damping, 1 = critical damping.
	public float dampingRatio;

}
